<template>
	<view :style="{paddingBottom:132 +bottomHight +'rpx',background:!jiesuoShow ?'#fff' :'#f4f4f4' }" class="container-box" >
		<!-- 先注释，app策划稿查企业不显示解锁20250321 -->
		<!-- <view class="jiesuo-box" v-if="!jiesuoShow">
			<view class="jiesuo-title">
				解锁“<view class="text-ellipsis">{{companyName}}</view>”的查企业
			</view>
			<view class="jiesuo-desc">
				查企业剩余可解锁次数：
			</view>
			<view class="jiesuo-cishu">
				<view v-for="(item,index) in shengyucishu" :key="index">{{item}}</view>
				<text>次</text>
			</view>
			<view class="jiesuo-tip d-b-c">
				<text>解锁后权限生效期间不会重复解锁</text>
				<text @click="zengjiacishu">增加可使用次数</text>
			</view>
			<view class="lijijiesuo" @click="lijijiesuo">立即解锁</view>
		</view> -->
		<!-- <view v-if="jiesuoShow"> -->
		<view>
			<view class="pub-inner">
				<view class="title d-b-c">
					<view class="title-left">
						数据概览
					</view>
				</view>
				<view class="shujugailan">
					<u-skeleton :loading="loading" :animate="true" :title="false" rows="7" rowsHeight="36rpx" style="margin-top: 10rpx;">
						<view class="item">
							<view class="item-label">
								注册类型
							</view>
							<view>{{companyData.base_company_type ?companyData.base_company_type :'--'}}</view>
						</view>
						<view class="item">
							<view class="item-label">成立日期</view>
							<view>{{companyData.base_estiblish_time ? companyData.base_estiblish_time :'--'}}</view>
						</view>
						<view class="item">
							<view class="item-label">营业期限</view>
							<view>{{businessTerm}}</view>
							<!-- <view v-if="(companyData.base_from_time=='--'&&companyData.base_to_time=='--') || JSON.stringify(companyData)=='{}'"  >--</view>
							<view v-else>{{companyData.base_from_time}} - {{companyData.base_to_time && companyData.base_to_time=='--' ? '无固定期限' :companyData.base_to_time}}</view> -->
						</view>
						<view class="item">
							<view class="item-label">注册资金</view>
							<view>{{companyData.base_reg_jine ? companyData.base_reg_jine :'--'}}</view>
						</view>
						<view class="item">
							<view class="item-label">信用代码</view>
							<view>{{companyData.base_credit_code ? companyData.base_credit_code :'--'}}</view>
						</view>
						<view class="item">
							<view class="item-label">行    业</view>
							<view>{{companyData.base_hangye ?companyData.base_hangye :'--'}}</view>
						</view>
						<view class="item">
							<view class="item-label">经营范围</view>
							<view class="jingyingfanwei">
								<view class="fanwei-txt" :class="{'text-ellipsis-1' : !isZhankai}">
									{{companyData.base_business_scope ? companyData.base_business_scope :'--'}}
								</view>
								<view class="zhankai" v-if="JSON.stringify(companyData)!=='{}'"  @click="zhankaiClick" >
									{{isZhankai ?'收起' :'展开'}}
								</view>
							</view>
						</view>
					</u-skeleton>
				</view>
			</view>
			
			<!-- app此处隐藏 20250318-->
			<!-- <view class="pub-inner" style="margin-bottom:28rpx;">
				<view class="title d-b-c">
					<view class="title-left">
						企业信息<text>请前往PC端查看</text>
					</view>
					<view class="title-right" @click="toxinxibiangeng">
						信息变更动态
					</view>
				</view>
				<view class="qyxxList">
					<view class="qyxx-item" v-for="(item,index) in qyxxList" :key="index" @click="qyxxClick">
						<img :src="item.src" alt="">
						<view>{{item.name}}</view>
					</view>
				</view>
			</view> -->
		</view>
		
	</view>
</template>

<script>
	export default {
		name: "Chaqiye",
		props: ['comcode', 'vcode', "companyData","danweiType","bottomHight","companyName","cqyjiesuoShow","cqyshengyucishu" ],
		data() {
			return {
				location: 10905,
				loading:true,
				isZhankai:false,
				qyxxList:[
					{
						src:'//img.bidcenter.com.cn/uni/qiqing/qyzz.png',
						name:'企业资质'
					},
					{
						src:'//img.bidcenter.com.cn/uni/qiqing/zgzz.png',
						name:'资格资质'
					},
					{
						src:'//img.bidcenter.com.cn/uni/qiqing/zcry.png',
						name:'注册人员'
					},
					{
						src:'//img.bidcenter.com.cn/uni/qiqing/gcxm.png',
						name:'工程项目'
					},
					{
						src:'//img.bidcenter.com.cn/uni/qiqing/flss.png',
						name:'法律诉讼'
					},
					{
						src:'//img.bidcenter.com.cn/uni/qiqing/fygg.png',
						name:'法院公告'
					},
					{
						src:'//img.bidcenter.com.cn/uni/qiqing/bzxr.png',
						name:'被执行人'
					},
					{
						src:'//img.bidcenter.com.cn/uni/qiqing/ktgg.png',
						name:'开庭公告'
					},
					{
						src:'//img.bidcenter.com.cn/uni/qiqing/jyyc.png',
						name:'经营异常'
					},
					{
						src:'//img.bidcenter.com.cn/uni/qiqing/xzcf.png',
						name:'行政处罚'
					},
					{
						src:'//img.bidcenter.com.cn/uni/qiqing/yzwf.png',
						name:'严重违法'
					},
					{
						src:'//img.bidcenter.com.cn/uni/qiqing/sbxx.png',
						name:'商标信息'
					},
					{
						src:'//img.bidcenter.com.cn/uni/qiqing/zlxx.png',
						name:'专利信息'
					},
					{
						src:'//img.bidcenter.com.cn/uni/qiqing/rjzzq.png',
						name:'软件著作权'
					},
				],
				jiesuoShow:this.cqyjiesuoShow,//解锁板块
				shengyucishu:[],
				
			};
		},

		watch: {
			companyData: {
				handler(a, b) {
					if(JSON.stringify(a)!=="{}" || this.companyName !==''){
						this.loading=false
					}
					
				},
				immediate: true
			},
			cqyshengyucishu: {
			      handler(a, b) {
				// console.log(a.toString().split(""));
				let arr = [];
				this.shengyucishu = a.toString().split("");
			  },
			  immediate: true,
			},
		},
		async mounted() {
			// console.log(222,this.jiesuoShow)
			this.$nextTick(() => {
				
			})

		},
		computed: {
			businessTerm() {
			      /**
			       * 张珈铭20250430
			       * 1.营业期限，结束时间大于开始时间时，只显示开始时间，不显示中间链接“—”及后面的时间数据
			       * 2.营业期限，结束时间为空时，，只显示开始时间，不显示中间链接“—”及后面的时间数据
			       */
			      // 无固定期限
			      const { base_from_time,base_to_time} = this.companyData;
			      let data = "--";
			      // let base_to_time= '1970-01-01'
			      if (base_from_time !== "--" && base_to_time !== "--" && base_to_time.includes('固定期限')) {
			        data = base_from_time + "至" + base_to_time;
			      } else if (base_from_time !== "--" && base_to_time === "--") {
			        data = base_from_time ;
			      } else if (base_from_time != "--" && base_to_time != "--" && !base_to_time.includes('固定期限')) {
			        let fromTime = new Date(base_from_time)
			        let toTime = new Date(base_to_time)
			        if(toTime.getTime()>fromTime.getTime()){
			          data = base_from_time ;
			        }else{
			          data = base_from_time + "至" + base_to_time;
			        }
			      }
			      return data;
			    },
		},

		methods: {
			//跳转至企业信息变更动态
			toxinxibiangeng(){
				uni.navigateTo({
					url:'/pages/qiqing/xinxibiangeng/index?company=' + this.companyName + '&comcode=' + this.comcode + '&vcode=' + this.vcode
				})
			},
			zhankaiClick(){
				this.isZhankai = !this.isZhankai
				
			},
			qyxxClick(){
				// console.log(this.danweiType)
				let link =''
				if(this.danweiType==2){
					//业主
					link = 'https://user.bidcenter.com.cn/v2023/#/saasApply/qiqing/zhaobiaofenxi/'+this.comcode+'/'+this.vcode
				}else if(this.danweiType==5){
					//供应商单位
					link = 'https://user.bidcenter.com.cn/v2023/#/saasApply/qiqing/zhongbiaofenxi/'+this.comcode+'/'+this.vcode
				}else if(this.danweiType==1){
					//代理机构单位
					link = 'https://user.bidcenter.com.cn/v2023/#/saasApply/qiqing/dailishangfenxi/'+this.comcode+'/'+this.vcode
				}
				uni.setClipboardData({
					data:link,
					success: () => {
						uni.$u.toast('功能搭建中，请前往PC端查看,已复制链接');
					},
					fail:(error)=> {
						console.log('失败',error);
						uni.showToast({
							title: '复制失败',
							icon: 'none'
						});
					}
								
				})
			},
			
			lijijiesuo(){
				this.jiesuoShow=true
				
				uni.$u.http
				.post("/analysis/Company/CompanyRyzzHandler.ashx", {
					comcode: this.comcode,
					vcode: this.vcode,
					zsname: '',
					pageindex: 1,
					pagesize:10,
					mid_yx: 247, // 247：企情分析
					log_yx: 0, // 是否记录主功能日志 0：否（默认）；1：是
					mid_cy: 254, // 254：企业信息
					log_cy: 1, // 是否记录次要功能日志 0：否（默认）；1：是
					log_type: 10464, // 10464：企情分析-企业信息
				})
				.then((rs) => {}).catch(err => {
					uni.$u.toast(err.msg);
				});
				setTimeout(()=>{
					this.$emit("getGongneng")
				},300)
			},
			// 增加查看次数
			zengjiacishu(){
				uni.navigateTo({
					url:'/pages/qiqing/pay/pay?type=' + 254 + '&pageurl=' + '/pages/qiqing/index' + '&comcode=' + this.comcode + '&vcode=' + this.vcode
				})
			}
		}

	}
</script>

<style scoped lang="scss">
	@import '@/static/css/index.scss';
	.container-box{
		min-height: 50vh;
		padding: 20rpx 28rpx 0;
		background: #f4f4f4;
	}
	.pub-inner {
		// margin-top: 20rpx;
		padding: 30rpx 28rpx;
		background: #fff;

		.title {
			
		}
		.title-left{
			font-size: 28rpx;
			color: #3B3E45;
			font-weight: bold;
			text{
				margin-left: 20rpx;
				font-size: 24rpx;
				color: #6C717E;
				font-weight: normal;
			}
		}
		.title-right{
			font-size: 24rpx;
			color: #2F6DFE;
		}
	}

	.shujugailan {
		.item {
			margin-top: 20rpx;
			font-size: 24rpx;
			color: #6C717E;
			display: flex;
			view {
				
				&:nth-child(2){
					margin-left: 36rpx;
					color: #3B3E45;
				}
				
			}
			.item-label{
				width: 98rpx;
				text-align: justify;
				 text-align-last:justify;
			}
			.jingyingfanwei{
				width: 81%;
				display: flex;
				justify-content: space-between;
				view{
					&:first-child{
						width: 90%;
						
					}
					&:nth-child(2){
						display: flex;
						align-items: flex-end;
						margin-left: 0rpx;
						color: #2F6DFE;
					}
				}
			}
			.fanwei-txt {
				// text-align: left;
				// text-align-last: auto;
			}
		}
	}
	
	.text-ellipsis-1 {
		display: -webkit-box;
		word-break: break-all;
		text-overflow: ellipsis;
		overflow: hidden;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 1;
		._root{
			overflow: inherit !important;
		} 
		view,text{
			display: inline !important;
		}
	}
	.bottom{
		display: flex;
		align-items: flex-end;
	}
	.qyxxList{
		margin-top: 24rpx;
		display: flex;
		flex-wrap: wrap;
		align-content: flex-start;
		margin-right: -10rpx;
		margin-bottom: 12rpx;
		.qyxx-item{
			width: 152rpx;
			padding: 18rpx 0;
			margin: 10rpx 10rpx 0 0;
			text-align: center;
			background: rgba(47,109,254,0.05);
			img{
				width: 48rpx;
				height: 48rpx;
			}
			view{
				font-size: 24rpx;
				color: #6C717E;
			}
		}
	}
	.jiesuo-box{
		padding: 30rpx 18rpx 50rpx;
		margin-top: 20rpx;
		text-align: center;
		background: linear-gradient(-90deg, #FFF8ED, #FFE9D5);
		border-radius: 10rpx;
		.jiesuo-title{
			display: flex;
			justify-content: center;
			font-size: 32rpx;
			color: #333333;
			view{
				max-width: 200rpx;
			}
		}
		.jiesuo-desc{
			margin-top: 26rpx;
			font-size: 26rpx;
			color: #6C717E;
		}
		.jiesuo-cishu{
			display: flex;
			justify-content: center;
			align-items: center;
			margin-top: 28rpx;
			text{
				font-size: 30rpx;
				color: #333;
			}
			view{
				margin-right: 20rpx;
				width: 60rpx;
				height: 60rpx;
				line-height: 60rpx;
				font-size: 36rpx;
				color: #836038;
				font-weight: bold;
				background: linear-gradient(0deg, #FFC760 0%, #FFE7AB 100%);
			}
		}
		.jiesuo-tip{
			margin-top: 34rpx;
			text{
				&:first-child{
					font-size: 28rpx;
					color: #333333;
				}
				&:last-child{
					font-size: 28rpx;
					color: #2F6DFE;
					font-weight: bold;
				}
			}
		}
		.lijijiesuo{
			width: 540rpx;
			height: 98rpx;
			line-height: 98rpx;
			margin: 52rpx auto 0;
			font-size: 36rpx;
			color: #836038;
			font-weight: bold;
			text-align: center;
			background: linear-gradient(-84deg, #FFC04D 0%, #FFE7AB 100%);
			border-radius: 49rpx;
		}
	}
	
</style>